<template>
  <div id="app" v-cloak>
    <keep-alive :include="include" :max="10">
      <router-view class="router" ref="router"></router-view>
    </keep-alive>

    <div v-if="this.$store.state.showbar">
      <van-tabbar v-model="active">
        <van-tabbar-item name='home' to="/" icon="home-o">首页</van-tabbar-item>
        <van-tabbar-item name='category' to="category" icon="search">分类</van-tabbar-item>
        <van-tabbar-item name='trolley' to="trolley" icon="friends-o">购物车</van-tabbar-item>
        <van-tabbar-item name='mine' to="user" icon="setting-o">我的</van-tabbar-item>
      </van-tabbar>
    </div>
  </div>
</template>

<script>
  function isKeepAlive($route) {
    return $route.meta.keepAlive === undefined || $route.meta.keepAlive;
  }
  export default {
    data() {
      return {
        active: '',
        include: isKeepAlive(this.$route) ? [this.$route.name] : [],
        history: []
      };
    },
    methods: {
    },
    provide() {
      return {
        app: this
      };
    },
    mounted() {
      this.active = this.$route.name;
    },
    components: {
    },
    watch: {
      $route(to, from) {
        console.log('watch route');
        console.log(to);
        console.log(from);
      }
    }
  }
</script>

<style lang="scss">
  [v-cloak] {
    display: none !important;
  }

  #app {
  font-family: Avenir, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
}

</style>
